$(document).ready(function () {
    var projectId = getQueryString("projectId");
    var stuNum = getQueryString("stuNum");
    var stuName = getQueryString("stuName");
    var termYear = getQueryString("termYear");
    var termNum = getQueryString("termNum");
    var projectName = getQueryString("projectName");
    var projectPlatform = getQueryString("projectPlatform");
    var projectContactPeople = getQueryString("projectContactPeople");
    var projectPhonenum = getQueryString("projectPhonenum");
    var projectStartDate = getQueryString("projectStartDate");
    var projectEndtDate = getQueryString("projectEndtDate");
   // alert("00000")
    $("input[name='stuNum']").val(stuNum);
    $("input[name='stuName']").val(stuName);
    $("input[name='termYear']").val(termYear);
    $("input[name='termNum']").val(termNum);
    $("input[name='projectName']").val(projectName);
    $("input[name='projectPlatform']").val(projectPlatform);
    $("input[name='projectContact']").val(projectContactPeople);
    $("input[name='projectPhonenum']").val(projectPhonenum);
    $("input[name='projectStartDate']").val(projectStartDate);
    $("input[name='projectEndtDate']").val(projectEndtDate);

});
//申请结项，申请后状态改为5申请中--更新社会实践表
$(document).on('click', '#apply-btn', function() {
    var projectId = getQueryString("projectId");
    var projectConclusion=$("textarea[name='projectConclusion']").val();
    if(projectConclusion==null||projectConclusion==""){
        layer.alert("总结不能为空");
        return false;
    }
    var projectState=5;
    $.ajax({
        url: "http://localhost:8080/finishProject/updateFinishProject",
        type: "GET",
        data:"projectId="+projectId+"&projectConclusion="+projectConclusion+"&projectState="+projectState,
        dataType: "json",
        success:function (data) {
            var msg="申请成功！请耐心等待！";
            $.each(data.data,function (key,value) {
                msg=value;
            });
            location.href='myFinishProject.html';
            layer.msg(msg);
        },
        error:function () {
            layer.msg("网络在开小差~稍后重试");
        }
    });
})

//获取url地址参数
function getQueryString(name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        //return unescape(r[2]);
        //decodeURI解码
        return decodeURI(decodeURI(r[2]));
    }
    return null;
}